<?php

namespace App\Models\CacheModel\chat;

use App\Models\Api\BaseCache;
use think\Log;

class HzChatRecordDetailsZanData2 extends BaseCache
{
    protected $table = 'wechat_backup_07_18_14_43_00.hz_chat_record_details_zan_data2';

    /**
     * 记录 赞同与反对
     * @param array $data
     * @return bool
     */
    public function setZan(array $data)
    {
        try
        {
            $this->where(['chat_detail_id' => $data['chat_detail_id']])->delete();
            $resData = [];
            if ($data['status'] > 0)
            {
                $resData = [
                    'uid' => $data['uid'],
                    'chat_detail_id' => $data['chat_detail_id'],
                    'status' => $data['status'],
                    'feedback_ids' => $data['feedback_ids'],
                    'pid' => $data['pid'],
                    'question' => $data['question'],
                    'replay' => $data['replay'],
                    'recode_info' => $data['recode_info'],
                    'model_name' => $data['model_name'],
                    'create_time' => time()
                ];
            }
            if ($resData)
            {
                $this->save($resData);
            }
            return true;
        }
        catch (\Exception $e)
        {
            Log::write('HzChatRecordDetailsZanData model => setZan()异常：' . $e->getMessage() . '失败行数：' . $e->getLine(), 'error');
            return false;
        }
    }
}
